
import random
# (a)
ArrayData = [[random.randint(1,100) for i in range(10)] for j in range(10)]
# (b)(ii)

#  输出不对 M: -1
def PrintArray():
    for i in range(0, 9): #M: -1
        for j in range(0, 9):#M: -1
            print(ArrayData[i][j],end=' ')
        print()
# (c)(i)
def BinarySearch(SearchArray, Lower, Upper, SearchValue):
    if Upper >= Lower:
        Mid = (Lower + (Upper - 1)) // 2 # -1
        if SearchArray[0][Mid] == SearchValue:
            return Mid
        else:
            if SearchArray[0][Mid] > SearchValue:
                return BinarySearch(SearchArray, Lower, Mid - 1, SearchValue)
            else:
                return BinarySearch(SearchArray, Mid + 1, Upper, SearchValue)
    return -1

if __name__ == '__main__':
    # (b)(i)
    print(PrintArray())
    ArrayLength= 10
    for X in range(0, ArrayLength - 1):
        for Y in range(0, ArrayLength - 2):
            for Z in range(0, ArrayLength - Y - 2):
                if ArrayData[X][Z] > ArrayData[X][Z + 1]:
                    TempValue = ArrayData[X][Z]
                    ArrayData[X][Z] = ArrayData[X][Z + 1]
                    ArrayData[X][Z + 1] = TempValue
    print(PrintArray())
    # (c)(ii)
    print(BinarySearch(ArrayData, 0, 9, int(input('input value to search: '))))
    print(BinarySearch(ArrayData, 0, 9, int(input('input value to search: ')))) # -1